package fegincosumerapp.openfeigncontroller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import fegincosumerapp.block.GlobalBlockHandler;
import fegincosumerapp.feign.UserFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pojo.User;

@RestController
public class OpenfeignController {
    @Autowired
    private UserFeignClient userFeignClient;

    @GetMapping("getUser")
    public User getUser(Integer id){
        return userFeignClient.getUser(id);
    }

    @GetMapping("/consumer/findId")
    @SentinelResource(value = "findId",
                      blockHandlerClass = GlobalBlockHandler.class,
                 blockHandler = "blockHandlerMethod")
    public User get(Integer id,String nam){
        return userFeignClient.getUser(id,nam);
    }


}
